
$(document).ready(function(){
	//页面地址
	var __PAGEURL = $(".page_url").val()+"?c=auction&";
	//统计
	statistics("tab-金币兑奖");
	/*-----------------begin 初始弹框---------------*/
	if(Number($("#isFirstTimeToAuction").val()) || 1==1){
		var _dingbu_html = '<div class="pop-exchange-boot">'+
				'<a href="javascript:;" class="close"></a>'+
				'<a href="javascript:;" class="btn close100"></a>'+
			'</div>';
		/*var _dingbu_html = '<div class="pop-exchange-boot-2"><a href="javascript:;" class="close"></a>'+
			'<a href="'+$(".page_url").val()+'" class="btn"></a></div>';*/
		$("#pop-content").html(_dingbu_html);
		openpop();
	}
	/*-----------------end 初始弹框---------------*/
	/*-----------------begin 设置提醒---------------*/
	/*$("h1 .settip").click(function(){
		fusion2.dialog.authReminder({
			onSuccess : function (opt) {tixingTanchuang();},
			onError : function (opt) { 
				if(opt.code==100) {
					tixingTanchuang();
				}
			},
			onCancel : function (opt) {}
		});
	});*/
	//提醒的方法
	function tixingTanchuang(){
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxRemind",
			//data: "id="+__id+"&offer="+__offer,
			dataType: "json",
			success: function(rs){
				
			}
		});
	}
	//中间、底部提醒
	$(".auction-foot-remind,.auction-page-remind").click(function(){
		__QQ_REMINDER();
		//统计
		statistics("全额兑换设置提醒");
	});
	/*-----------------end 设置提醒---------------*/
	/*-----------------begin 1.兑换规则 2.竞拍规则---------------*/
	//1.兑换规则
	$(".duihuanGuize").click(function(){
		var __duihuan_guize_html = '<div class="exchange_rules">'+
			'<a href="javascript:;" class="close">关闭</a>'+
			'<a href="javascript:;" class="exchange_getgold task">做任务赚金币</a></div>';
		$("#pop-content").html(__duihuan_guize_html);
		openpop();
		return false;
	});
	//2.竞拍规则
	$(".jinpaiGuize").click(function(){
		var __jingpai_guize_html = '<div class="auction_rules">'+
			'<a href="javascript:;" class="close">关闭</a>'+
			'<a href="javascript:;" class="auction_getgold task">&gt;&gt; 免费获取金币</a></div>';
		$("#pop-content").html(__jingpai_guize_html);
		openpop();
		return false;
	});
	/*-----------------end   1.兑换规则 2.竞拍规则---------------*/
	/*-----------------begin 1.出价 2.我的出价---------------*/
	//--- 1.出价 ---//
	$(".give_price").click(function(){
		var __this = $(this);
		var __id = __this.data("agid");//竞拍商品id
		var __offer_ele = __this.parents(".auction-list-item").find(".input_price");//价格element
		var __offer = __offer_ele.val();//价格
		var __gold1 = $(".gold_corn #gold");//金币1
		var __gold2 = $(".gold-number .alert-color");//金币2
		var __offer_e = __this.parents(".auction-list-item").find(".input_price");//价格element
		var __goodsprice = __this.parents(".auction-list-item").find(".goodsprice");//商品价格
		var __historyoffer = __this.parents(".auction-list-item").find(".auction_right ul");//历史竞拍出价
		var __selfoffer = __this.parents(".auction-list-item").find(".history_notes ul");//我的出价
		var __offertime = __this.parents(".auction-list-item").find(".offertime"); //出价次数
		//出价区间error
		if(isNaN(__offer) || !__offer || __offer>1000 || __offer<=0.009){
			fusion2.ui.showMsgbox({
				type: 1,
				msg: "太吃亏了，请输入少于1000大于0.01的价格！",
				timeout: 1000
			});
			return false;
		}
		//出价正常
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxUserOffer",
			data: "id="+__id+"&offer="+__offer,
			dataType: "json",
			success: function(rs){
				//fusion2.ui.hideMsgbox();
				if(rs.ret<0) fusion2.ui.showMsgbox({type: 3,msg: rs.msg,timeout: 1000});
				if(rs.ret==1) {
					fusion2.ui.showMsgbox({type: 2,msg: "恭喜出价成功！记得明天来查看领奖哦~~",timeout: 1000});
					__gold1.text(parseInt(__gold1.text())-10); //金币消耗1
					__gold2.text(parseInt(__gold1.text())); //金币消耗2
					__offer_e.val((parseFloat(__goodsprice.text())/20*(Math.random())).toFixed(2));//随机价格
					//历史竞拍
					var __historyoffer_html = '';
				    $.each( rs.historyOffer, function(i, n){
				    	__historyoffer_html += '<li class="trends clearfix"><div class="list_img_out"><img src="'+n.figureurl+'"></div>'+
		                	'<div class="trends_list"><p class="nickname"><span class="nickname_user" title="'+n.nickname+'">'+n.nickname+'</span><span class="time_before">（'+n.shicha+'）</span></p>'+
		                	'<p class="can_give">出价：'+n.offer+'元</p></div></li>';
					});
				    __historyoffer.html(__historyoffer_html);
				    //个人竞拍
				    var __selfoffer_html = '';
				    $.each(rs.selfOffer, function(i, n){
				    	__selfoffer_html+='<li class="price_note">出价<span class="note_price">'+n.offer+'元</span>'+n.shicha+'</li>';
				    });
				    __selfoffer.html(__selfoffer_html);
				    //出价次数
				    __offertime.text(rs.totalOffer);
				}
			}
		});
		return false;
	});
	//--- 2.我的出价 ---//
	//2.1 打开
	$('.history_link').click(function(){
		$(this).parents('.auction_content').find('.form_sub div').show();
	});
	//2.2 关闭
	$('.close_notes').click(function(){
		$(this).parents('.auction_content').find('.form_sub div').hide();
	});
	/*-----------------end  1.出价 2.我的出价---------------*/
	/*-----------------begin  轮播---------------*/
	function movelist(){
		$('.top_right_lists>li:first-child').animate({'margin-top':'-33px'},2000,function(){
			$(this).css({'margin-top':'0'}).appendTo('.top_right_lists')
		});
		movetime=setTimeout(movelist,2500);
	}
	movelist();
	$('.top_right_lists').hover(function(){
		clearTimeout(movetime);
	},function(){
		movelist();
	});
	/*-----------------end   轮播---------------*/
	/*============================兑换==============================*/
	$(".list-exchange a").click(function(){
		var _this   = $(this);
		var __li    = _this.parents("li");
		var _status = __li.find(".exchange1").data("status"); //状态
		var _id     = __li.data("id"); //id
		var _url    = __li.data("url"); //url
		var _img    = __li.children("a").children("img").attr("src");//图片
		var _price  = __li.find(".price strong").text();//价格
		var _num    = __li.find(".count strong").text();//剩余数量
		var _name   = __li.children("a").children("h4").text();//商品名
		var _gold   = __li.find(".num strong").text();//金币
		//AjaxExchangeQuest
		$.ajax({
			url: __PAGEURL+"m=AjaxExchange",
			data: "id="+_id+"&status="+_status+"&",
			dataType: "json",
			success: function(data){
				fusion2.ui.hideMsgbox();
				//错误处理
				if(data.ret<0){
					fusion2.ui.showMsgbox({type: 1,msg: data.msg,timeout: 1000});
					return false;
				}
				//正常
				var _html2 = _html3 = _html4 = "";
				var _html5 = "兑换名额";
				if(_status==1 || _status==0){//1.正在兑换0.已经结束
					_num = data.num;//商品数
					//已经兑换成功
					if(data.ret==2){
						_html2 = '<div class="exchange-state exchange-state-success">'+
									'<div class="exchange-state-con">'+
										'<h3>恭喜您兑换成功！！<a href="javascript:;" class="xuanyao">马上炫耀一下</a></h3>'+
										'<p>您的兑奖密码是：<input type="text" class="copy_convert" value="'+data.pwd+'" readonly="" disabled="disabled"><a href="javascript:;" class="btn-link">复制</a></p>'+
										'<p class="tiptext">您将免费获得该款商品,兑奖不收取任何费用。<br><a href="javascript:;" class="contact_us">联系优品客服兑奖</a></p>'+
									'</div>'+
								'</div>';
					}
					//没有兑换成功的
					$.each( data.exchangeList, function(i, n){
						_html3 += '<tr>'+
									'<td><img src="'+n.figureurl+'" class="pic"></td>'+
									'<td><span class="name">'+n.nickname+'</span></td>'+
									'<td><span class="sex">'+n.gender+'</span></td>'+
									'<td><span class="city">'+n.city+'</span></td>'+
									'<td><span class="gold"><b>'+n.exchangeGold+'</b>金币</span></td>'+
									'<td><span class="date">'+n.auctionTime2+'</span></td>'+
								'</tr>';
						if(data.ret!=2 && _status==0) _html4 += '<li><img src="'+n.figureurl+'"><p class="nick">'+n.nickname+'</p>'+
													'<p class="date">'+n.auctionTime1+'</p></li>';
					});
					if(data.ret!=2 && _status==1) _html2 = '<div class="exchange-state exchange-state-start">'+
								'<div class="exchange-state-con"><h3><b>题目：</b>'+data.question.question+'</h3>'+
									'<p><label for="exchange_shop_answer">答案：</label><input type="text" id="exchange_shop_answer"></p>'+
									'<div class="btn-outer"><a href="javascript:;" class="exchange2 btn" data-answer="'+data.question.answer+'" data-id="'+_id+'">立即兑换</a></div>'+
								'</div></div>';
					if(data.ret!=2 && _status==0){ 
						_html2 = '<div class="exchange-state exchange-state-winer">'+
								'<div class="exchange-state-con"><h3>中奖名单</h3><ul>'+_html4+'</ul></div></div>';
						_html5 = "中奖名额";
					}
				}else if(_status==-1){//-1.还没开始
					var _guanzhu = __li.find(".exchange1").data("guanzhu");
					if(data.ret!=2){
						 _html2 = '<div class="exchange-state exchange-state-begin">'+
						'<div class="exchange-state-con exchange-state-time"><h3>距开抢还有：0小时3分31.8秒</h3>'+
							'<p><b>'+_guanzhu+'</b>人想要，手快有手慢无！</p>'+
							'<div class="btn-outer"><a href="javascript:;" class="btn">即将开始</a></div>'+
						'</div></div>';
					}
				}
				var _html = '<div class="module-code">'+
				'<div id="js-look-history" class="look_history pop-exchange-all" >'+
				'<div class="title_bg"><h2 class="begin_auction_title">兑换详情</h2><span class="box_close2">关闭</span></div>'+
				'<div class="history_auction">'+
					'<div class="shop-info clearfix">'+
						'<a href="javascript:;" onclick="fusion2.nav.open({url : &quot;'+_url+'&quot;}); return false;" class="pic"><img src="'+_img+'"></a>'+
						'<a href="javascript:;" onclick="fusion2.nav.open({url : &quot;'+_url+'&quot;}); return false;" class="name">'+_name+'</a>'+
						'<p class="need">兑换所需金币：<strong>'+_gold+'</strong></p>'+
						'<div class="other clearfix"><span class="price">价值：<strong>'+_price+'</strong>元</span>'+
							'<span class="count">'+_html5+'：<strong>'+_num+'</strong>个</span></div>'+
						_html2+
					'</div>'+
					'<div class="shop-exchange-record">'+
						'<h3>兑换记录</h3>'+
						'<table><thead>'+
								'<tr><th width="50">头像</th><th width="80">昵称</th><th width="50">性别</th>'+
									'<th width="80">城市</th><th width="110">消耗金币</th><th>兑换时间</th></tr>'+
							'</thead>'+
							'<tbody>'+_html3+
							'</tbody>'+
						'</table>'+
					'</div>'+
				'</div></div></div>';
				$("#pop-content").html(_html);
				openpop();
				/* 全额兑换剩余时间 */
				var timeNow=$("#time_now").val();
				var timeEnd2=$("#time_ten_clock").val();
				var _shop_info = $(".shop-info");
				$(".exchange-state-time h3").countdown({timeRemaining:timeEnd2-timeNow,callback:function(){
					//$(".exchange-state-time h3").html("距开抢还有：00小时00秒00分");	--妮妮万岁
					//兑换问题
					$.ajax({
						url: __PAGEURL+"m=AjaxExchangeQuestion",
						dataType: "json",
						success: function(data){
							fusion2.ui.hideMsgbox();
							var _html = '<div class="exchange-state exchange-state-start">'+
							'<div class="exchange-state-con"><h3><b>题目：</b>'+data.question.question+'</h3>'+
								'<p><label for="exchange_shop_answer">答案：</label><input type="text" id="exchange_shop_answer"></p>'+
								'<div class="btn-outer"><a href="javascript:;" class="exchange2 btn" data-answer="'+data.question.answer+'" data-id="'+_id+'">立即兑换</a></div>'+
							'</div></div>';
							_shop_info.children(".exchange-state").remove();
							_shop_info.append(_html);
						}
					});
				}});
				//一键复制
			    $(".btn-link").zclip({
			        path: 'javascript/ZeroClipboard.swf',
			        copy: function () { return $('.copy_convert').val(); },
			        beforeCopy: function () {
			            $(this).css('color', 'orange');
			        },
			        afterCopy: function () {
			            $(this).css('color', 'purple');
			            fusion2.ui.showMsgbox({type: 2,msg: "复制成功！",timeout: 1000});
			        }
			    });
				
			}
		});
		return false;
	});
	//兑换
	$(".exchange-state-start").find(".btn").live("click",function(){
		var _input_val = $(this).parents(".exchange-state").find("#exchange_shop_answer").val();
		var _answer = $(this).data("answer");
		if(!_input_val){//空答案
			fusion2.ui.showMsgbox({type: 1,msg: "答案错误",timeout: 1000});
			return false;
		}
		if(_input_val!=_answer){//答案错误
			fusion2.ui.showMsgbox({type: 1,msg: "答案错误",timeout: 1000});
			return false;
		}
		//正常情况
		var _id = $(this).data("id");
		$.ajax({
			url: __PAGEURL+"m=AjaxExchange2",
			data: "id="+_id+"&",
			dataType: "json",
			success: function(data){
				fusion2.ui.hideMsgbox();
				if(data.ret<0){//特殊情况
					fusion2.ui.showMsgbox({type: 1,msg: data.msg,timeout: 1000});
					return false;
				}
				var _shop_info = $(".shop-info");
				if(data.ret==0){//金币不足
					var _html = '<div class="exchange-state exchange-state-enough" >'+
									'<div class="exchange-state-con">'+
										'<h3>您的金币数量不够<i>!!!</i></h3>'+
										'<p>立即去&gt;&gt; <a href="javascript:;">做任务赚金币</a></p>'+
									'</div>'+
								'</div>';
					_shop_info.children(".exchange-state").remove();
					_shop_info.append(_html);
					$(".exchange-state-enough a").click(function(){$(".task").click();});
				}
				if(data.ret==1){//兑换成功 userExchangeSucc
					var _html = '<div class="exchange-state exchange-state-success">'+
									'<div class="exchange-state-con">'+
										'<h3>恭喜您兑换成功！！<a href="javascript:;" class="xuanyao">马上炫耀一下</a></h3>'+
										'<p>您的兑奖密码是：<input type="text" class="copy_convert" value="'+data.pwd+'" readonly="" disabled="disabled"><a href="javascript:;" class="btn-link">复制</a></p>'+
										'<p class="tiptext">您将免费获得该款商品,兑奖不收取任何费用。<br><a href="javascript:;" class="contact_us">联系优品客服兑奖</a></p>'+
									'</div>'+
								'</div>';
					_shop_info.children(".exchange-state").remove();
					_shop_info.append(_html);
					var _html = '<tr>'+
									'<td><img src="'+data.userExchangeSucc.figureurl+'" class="pic"></td>'+
									'<td><span class="name">'+data.userExchangeSucc.nickname+'</span></td>'+
									'<td><span class="sex">'+data.userExchangeSucc.gender+'</span></td>'+
									'<td><span class="city">'+data.userExchangeSucc.city+'</span></td>'+
									'<td><span class="gold"><b>'+data.userExchangeSucc.exchangeGold+'</b>金币</span></td>'+
									'<td><span class="date">'+data.userExchangeSucc.auctionTime2+'</span></td>'+
								'</tr>';
					$(".shop-exchange-record").find("tbody").prepend(_html);
					//_shop_info.find(".other .count strong").text(data.num);
					//$(".list-exchange ul li[data-id='"+_id+"']").find(".count strong").text(data.num);
					if(data.num==0) $(".list-exchange ul li[data-id='"+_id+"']").find(".action a").attr("class","exchange1 btn btn-end").text("兑换结束").data("status",0);
					//金币变更
					var __gold_num = $(".gold_corn #gold");
					var __gold_num_true = parseInt(__gold_num.text())-data.userExchangeSucc.exchangeGold;
					__gold_num.text(__gold_num_true);//用户金币数
					$(".gold-number .alert-color").text(__gold_num_true);
				}
				if(data.ret==2){//已被抢完
					var _html = '<div class="exchange-state exchange-state-end">'+
									'<div class="exchange-state-con">'+
										'<h3>宝贝已被抢完<i>!!!</i></h3>'+
										'<p>下次记得早点来，还有下手要快准狠<i>!</i></p>'+
										'<a href="javascript:;" class="setremind">设置提醒</a>'+
									'</div></div>';
					_shop_info.children(".exchange-state").remove();
					_shop_info.append(_html);
					$(".list-exchange ul li[data-id='"+_id+"']").find(".action a").attr("class","exchange1 btn btn-end").text("兑换结束").data("status",0);
					//结果
					var _html3 = '';
					$.each( data.exchangeList, function(i, n){
						_html3 += '<tr>'+
							'<td><img src="'+n.figureurl+'" class="pic"></td>'+
							'<td><span class="name">'+n.nickname+'</span></td>'+
							'<td><span class="sex">'+n.gender+'</span></td>'+
							'<td><span class="city">'+n.city+'</span></td>'+
							'<td><span class="gold"><b>'+n.exchangeGold+'</b>金币</span></td>'+
							'<td><span class="date">'+n.auctionTime2+'</span></td>'+
						'</tr>';
					});
					$(".shop-exchange-record").find("tbody").html(_html3);
					//设置提醒
					$(".setremind").click(function(){
						__QQ_REMINDER();
					});
				}
				//一键复制
			    $(".btn-link").zclip({
			        path: 'javascript/ZeroClipboard.swf',
			        copy: function () { return $('.copy_convert').val(); },
			        beforeCopy: function () {
			            $(this).css('color', 'orange');
			        },
			        afterCopy: function () {
			            $(this).css('color', 'purple');
			            fusion2.ui.showMsgbox({type: 2,msg: "复制成功！",timeout: 1000});
			        }
			    });
			}
		});
		return false;
	});

	/* ----------------------------------------------------------------------------------------
     * ----------------------------------------免费竞拍历史----------------------------------------
     * ---------------------------------------------------------------------------------------- */
	/*-----------------begin 1.1获奖竞拍详情弹框---------------*/
	$(".jinpaiXq").click(function(){
		var __id = $(this).data("id");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxAuctionSuccInfo",
			data: "id="+__id+"&",
			dataType: "json",
			success: function(rs){
				fusion2.ui.hideMsgbox();
				//alert( "Data Saved: " + rs.id );
				var __jingpai_xiangq_html = '<div id="js-look-history" class="look_history auction_box"><div class="title_bg">'+
					'<h2 class="begin_auction_title">竞拍详情</h2><span class="box_close2"></span></div>'+
					'<div class="history_auction"><div class="history_auction_top clearfix">'+
					'<div class="auction_img_outer">'+
						'<a class="market_buy" href="javascript:void(0);" style="display: none;"  onclick="fusion2.nav.open({url : \"'+rs.url+'\"}); return false;">没有获奖？！人品没爆发，那就自己去买吧&gt;&gt;</a>'+
						'<span style="display: none;"></span>'+
						'<a href="javascript:void(0);" onclick="fusion2.nav.open({url : \''+rs.url+'\'}); return false;"><img src="'+rs.pic+'" style="width: 250px; height: 250px;"></a>'+
						'</div>'+
					'<div class="winner_info"><div class="winner_information clearfix">'+
						'<img class="winner_pix" src="'+rs.figureurl+'" style="width: 50px; height: 50px;">'+
						'<div class="winner_detail">'+
						'<p class="winner_desc">'+rs.nickname+'</p>'+
						'<p class="win_gender_outer"><span>性别：'+rs.gender+'</span><span>城市：'+rs.city+'</span></p>'+
					'</div></div>'+
					'<div class="winner_box">'+
						'<p class="winner_lower">唯一最低价：<span class="winner_number">'+rs.offer+'</span>元</p>'+
						'<p class="auctioned_time">出价时间：<span>'+rs.auctionTime+'</span></p>'+
					'</div><div class="pro_tips"><font>TA将免费获得：</font>'+
						'<span>市场价：'+rs.pirce+'元</span>的<span>'+rs.name+'</span>'+
							'<a class="opener" href="javascript:void(0)" style="display: none;" class="contact_us"><span>联系优品客服</span></a>'+           
					'</div></div></div>'+
					'<div class="history_auction_bottom"><p class="other_auction_price">其他出价</p>'+
					'<table class="price_record"><tbody>'+
						'<tr><td></td><td></td><td></td><td></td><td></td></tr>'+
						'<tr style="background-color: rgb(253, 243, 252);"><td></td><td></td><td></td><td></td><td></td></tr>'+
						'<tr><td></td><td></td><td></td><td></td><td></td></tr>'+
						'<tr style="background-color: rgb(253, 243, 252);"><td></td><td></td><td></td><td></td><td></td></tr>'+
						'<tr><td></td><td></td><td></td><td></td><td></td></tr>'+
						'<tr style="background-color: rgb(253, 243, 252);"><td></td><td></td><td></td><td></td><td></td></tr>'+
					'</tbody></table>'+
					'</div></div></div>';
				$("#pop-content").html(__jingpai_xiangq_html);
				openpop();
				$.each( rs.offerdetail, function(i, n){
					var _this_td = $(".price_record").find("td").eq(i);
					
					_this_td.text(n.offer+"元  ： "+n.cid+" 次");
					if(n.islowest==1) _this_td.addClass("lowest");
				});
			}
		});
		return false;
	});
	/*-----------------end 1.1获奖竞拍详情弹框---------------*/
	/*-----------------begin 1.2获奖竞拍密码弹框---------------*/
	$(".auction-code").click(function(){
		var _id = $(this).data("id");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxUserAuctionSuccInfo",
			data: "id="+_id+"&",
			dataType: "json",
			success: function(rs){
				fusion2.ui.hideMsgbox();
				var _html = '<div id="js-look-history" class="look_history auction_box">'+
				'<div class="title_bg"><h2 class="begin_auction_title">竞拍详情</h2><span class="box_close2"></span></div>'+
				'<div class="history_auction">'+
					'<div class="history_auction_top clearfix">'+
						'<div class="auction_img_outer">'+
							'<a class="market_buy" href="javascript:void(0);" style="display: none;" onclick="fusion2.nav.open({url : \"'+rs.url+'\"});" return="" false;"="">没有获奖？！人品没爆发，那就自己去买吧&gt;&gt;</a>'+
							'<span style="display: none;"></span>'+
							'<a href="javascript:void(0);" onclick="fusion2.nav.open({url : \''+rs.url+'\'}); return false;"><img src="'+rs.pic+'" style="width: 250px; height: 250px;"></a>'+
						'</div>'+
						'<div class="winner_info">'+
							'<p class="code_success">'+
								'<img class="winner_pix" src="'+rs.figureurl+'" width="50" height="50" style="width: 35px; height: 35px;">'+
								'<span class="code_winner">'+rs.nickname+'</span>'+
								'<span class="tips">'+
									'<font>恭喜您竞拍成功！</font>'+
									'<a href="javascript:void(0)" class="sent_invite xuanyao">炫耀一下，还有100金币哦&gt;&gt;</a>'+
								'</span>'+
							'</p>'+
							'<div class="winner_box2">'+
								'<p class="winner_lower">唯一最低价：<span class="winner_number">'+rs.offer+'</span>元</p>'+
								'<p class="auctioned_time">出价时间：<span>'+rs.auctionTime+'</span></p>'+
							'</div>'+
							'<div class="pro_tips winner_box"><p class="user_code">您的兑奖密码是：<input type="text" class="out_code" id="invitetext" value="'+rs.pwd+'"><span id="clip_container"><a class="code_copy" id="clip_button" href="javascript:void(0);" onclick="oCopy()">复制</a></span></p><div style="position: absolute; left:244px; top: 3px; width: 28px; height: 20px; z-index:99;"><embed id="ZeroClipboardMovie_1" src="http://i.fanhuan.org/images/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="29" height="20" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=29&amp;height=20" wmode="transparent"></div><p></p>'+
								'<font>TA将免费获得：</font>'+
								'<span>市场价：'+rs.pirce+'元</span>的<span>'+rs.name+'</span>'+
								'<a href="javascript:void(0)" onclick="window.open(\'http://wpa.qq.com/msgrd?V=1&amp;Uin=1679171821&amp;Exe=QQ&amp;Site=rc.qzone.qq.com/100656353&amp;Menu=No\'); return false;" class="contact_us"><span>联系优品客服</span></a>'+           
							'</div>'+
						'</div>'+
					'</div>'+
					'<div class="history_auction_bottom">'+
						'<p class="other_auction_price">其他出价</p>'+
						'<table class="price_record">'+
							'<tbody>'+
								'<tr><td></td><td></td><td></td><td></td><td></td></tr>'+
								'<tr style="background-color: rgb(253, 243, 252);"><td></td><td></td><td></td><td></td><td></td></tr>'+
								'<tr><td></td><td></td><td></td><td></td><td></td></tr>'+
								'<tr style="background-color: rgb(253, 243, 252);"><td></td><td></td><td></td><td></td><td></td></tr>'+
								'<tr><td></td><td></td><td></td><td></td><td></td></tr>'+
								'<tr style="background-color: rgb(253, 243, 252);"><td></td><td></td><td></td><td></td><td></td></tr>'+
							'</tbody>'+
						'</table>'+
					'</div></div></div>';
				$("#pop-content").html(_html);
				openpop();
				$.each( rs.offerdetail, function(i, n){
					var _this_td = $(".price_record").find("td").eq(i);
					
					_this_td.text(n.offer+"元  ： "+n.cid+" 次");
					if(n.islowest==1) _this_td.addClass("lowest");
				});
			}
		});
		return false;
	});
	$('.auction_img_outer').live('mouseover mouseout', function(event) {
		if (event.type == 'mouseover') {
			$(this).find("a.market_buy,span").stop(true,true).slideToggle();
		} else {
			//$(this).find("a.market_buy,span").stop(true,true).slideToggle();
		}
	});
	/*-----------------end 1.2获奖竞拍密码弹框---------------*/
	/*-----------------begin 2.1获奖兑换详情弹框---------------*/
	$(".duihuanXq").click(function(){
		var _id = $(this).data("id");
		var _pdate = $(this).data("pdate");
		
		var __li = $(this).parents("li");
		var _url = __li.data("url");
		var _title = __li.find(".auction-prize span b").text();
		var _pic = __li.children(".auction-prize").children("img").attr("src");
		var _price = __li.find(".auction-prize span font span").text();
		var _exchangeGold = $(this).data("exchangegold");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxExchangeSuccInfo",
			data: "id="+_id+"&pdate="+_pdate+"&",
			dataType: "json",
			success: function(data){
				fusion2.ui.hideMsgbox();
				if(data.ret<0){//特殊情况
					fusion2.ui.showMsgbox({type: 1,msg: data.msg,timeout: 1000});
					return false;
				}
				var _html2 = _html3 = '';
				if(data.num>0){
					$.each( data.data, function(i, n){
						_html3 += '<tr>'+
									'<td><img src="'+n.figureurl+'" class="pic"></td>'+
									'<td><span class="name">'+n.nickname+'</span></td>'+
									'<td><span class="sex">'+n.gender+'</span></td>'+
									'<td><span class="city">'+n.city+'</span></td>'+
									'<td><span class="gold"><b>'+n.exchangeGold+'</b>金币</span></td>'+
									'<td><span class="date">'+n.auctionTime2+'</span></td>'+
								'</tr>';
						_html2 += '<li><img src="'+n.figureurl+'"><p class="nick">'+n.nickname+'</p>'+
								'<p class="date">'+n.auctionTime1+'</p></li>';
					});
				}
				var _html = '<div class="module-code"><div id="js-look-history" class="look_history pop-exchange-all">'+
				'<div class="title_bg">'+
						'<h2 class="begin_auction_title">兑换详情</h2>'+
						'<span class="box_close2">关闭</span>'+
				'</div>'+
				'<div class="history_auction">'+
					'<div class="shop-info clearfix">'+
						'<a href="javascript:void(0);" onclick="fusion2.nav.open({url : \''+_url+'\'}); return false;" class="pic" ><img src="'+_pic+'" alt=""></a>'+
						'<a href="javascript:void(0);" onclick="fusion2.nav.open({url : \''+_url+'\'}); return false;" class="name">'+_title+'</a>'+
						'<p class="need">兑换所需金币：<strong>'+_exchangeGold+'</strong></p>'+
						'<div class="other clearfix">'+
							'<span class="price">价值：<strong>'+_price+'</strong>元</span>'+
							'<span class="count">兑换名额：<strong>'+data.num+'</strong>个</span>'+
						'</div>'+
						'<div class="exchange-state exchange-state-winer">'+
							'<div class="exchange-state-con">'+
								'<h3>中奖名单</h3>'+
								'<ul>'+_html2+'</ul>'+
							'</div>'+
						'</div>'+
					'</div>'+
					'<div class="shop-exchange-record">'+
						'<h3>兑换记录</h3>'+
						'<table>'+
							'<thead><tr><th width="50">头像</th><th width="80">昵称</th><th width="50">性别</th><th width="80">城市</th><th width="110">消耗金币</th><th>兑换时间</th></tr></thead>'+
							'<tbody>'+_html3+'</tbody>'+
						'</table>'+
					'</div></div></div></div>';
				$("#pop-content").html(_html);
				openpop();
			}
		});
		return false;
	});
	/*-----------------end 2.1获奖兑换详情弹框---------------*/
	/*-----------------begin 2.2获奖兑换密码弹框---------------*/
	$(".exchange-code").click(function(){
		var _id = $(this).data("id");
		var _pdate = $(this).data("pdate");
		var __li = $(this).parents("li");
		var _title = __li.find("h4 span").text();
		var _pic = __li.children("img").attr("src");
		var _price = __li.find(".list1-action1 .bigger strong").text();
		var _exchangeGold = $(this).data("exchangegold");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxUserExchangeSuccInfo",
			data: "id="+_id+"&pdate="+_pdate+"&",
			dataType: "json",
			success: function(data){
				fusion2.ui.hideMsgbox();
				var _html2 = _html3 = '';
				_html2 += '<div class="exchange-state exchange-state-success">'+
								'<div class="exchange-state-con">'+
									'<h3>恭喜您兑换成功！！<a href="javascript:;" class="xuanyao">马上炫耀一下</a></h3>'+
									'<p>您的兑奖密码是：<input type="text" class="copy_convert" value="'+data.self.pwd+'" readonly="" disabled="disabled"><a href="javascript:;" class="btn-link">复制</a></p>'+
									'<p class="tiptext">您将免费获得该款商品,兑奖不收取任何费用。<br><a href="javascript:;" class="contact_us">联系优品客服兑奖</a></p>'+
								'</div>'+
							'</div>';
				if(data.num>0){
					$.each( data.data, function(i, n){
						_html3 += '<tr>'+
									'<td><img src="'+n.figureurl+'" class="pic"></td>'+
									'<td><span class="name">'+n.nickname+'</span></td>'+
									'<td><span class="sex">'+n.gender+'</span></td>'+
									'<td><span class="city">'+n.city+'</span></td>'+
									'<td><span class="gold"><b>'+n.exchangeGold+'</b>金币</span></td>'+
									'<td><span class="date">'+n.auctionTime2+'</span></td>'+
								'</tr>';
					});
				}
				var _html = '<div class="module-code"><div id="js-look-history" class="look_history pop-exchange-all">'+
				'<div class="title_bg">'+
						'<h2 class="begin_auction_title">兑换详情</h2>'+
						'<span class="box_close2">关闭</span>'+
				'</div>'+
				'<div class="history_auction">'+
					'<div class="shop-info clearfix">'+
						'<a href="javascript:;" class="pic" onclick="fusion2.nav.open({url : \''+data.self.url+'\'}); return false;"><img src="'+_pic+'" alt=""></a>'+
						'<a href="javascript:;" class="name" onclick="fusion2.nav.open({url : \''+data.self.url+'\'}); return false;">'+_title+'</a>'+
						'<p class="need">兑换所需金币：<strong>'+_exchangeGold+'</strong></p>'+
						'<div class="other clearfix">'+
							'<span class="price">价值：<strong>'+_price+'</strong>元</span>'+
							'<span class="count">兑换名额：<strong>'+data.num+'</strong>个</span>'+
						'</div>'+_html2+
					'</div>'+
					'<div class="shop-exchange-record">'+
						'<h3>兑换记录</h3>'+
						'<table>'+
							'<thead><tr><th width="50">头像</th><th width="80">昵称</th><th width="50">性别</th><th width="80">城市</th><th width="110">消耗金币</th><th>兑换时间</th></tr></thead>'+
							'<tbody>'+_html3+'</tbody>'+
						'</table>'+
					'</div></div></div></div>';
				$("#pop-content").html(_html);
				openpop();
				//一键复制
			    $(".btn-link").zclip({
			        path: 'javascript/ZeroClipboard.swf',
			        copy: function () { return $('.copy_convert').val(); },
			        beforeCopy: function () {
			            $(this).css('color', 'orange');
			        },
			        afterCopy: function () {
			            $(this).css('color', 'purple');
			            fusion2.ui.showMsgbox({type: 2,msg: "复制成功！",timeout: 1000});
			        }
			    });
			    //一键复制
			    $(".btn-link").zclip({
			        path: 'javascript/ZeroClipboard.swf',
			        copy: function () { return $('.copy_convert').val(); },
			        beforeCopy: function () {
			            $(this).css('color', 'orange');
			        },
			        afterCopy: function () {
			            $(this).css('color', 'purple');
			            fusion2.ui.showMsgbox({type: 2,msg: "复制成功！",timeout: 1000});
			        }
			    });
			}
		});
		return false;
	});
	/*-----------------end 2.2获奖兑换密码弹框---------------*/
	/*-----------------begin 3.1通用 炫耀---------------*/
	$(".xuanyao").live("click",function(){
		fusion2.dialog.sendStory({
			msg: "哈哈~~每日限量超低折扣哦,我在这淘得很嗨,你也来逛一下吧~~",
			summary: "亲~我们每天都为您推荐10款最in最优惠的宝贝,记得来看哦!",
			title: "我在玩优品购物",
			img: "http://ctc.qzonestyle.gtimg.cn/qzonestyle/act/qzone_app_img/app100656353_100656353_100.png",
			context: "",
			onSuccess: function() {
				sharesuccess();
			}
		});
		return false;
	});
	$(".contact_us").live("click",function(){
		fusion2.dialog.addPal ({
			openid : "B1084F5A5562977E35A68F527C0E6B72",
			context : "成功添加优品客服为好友",
			onSuccess : function (opt){ 
				fusion2.ui.showMsgbox({type:2, msg:opt.context, timeout:2000});
				window.open("http://wpa.qq.com/msgrd?v=3&uin=1679171821&site=qq&menu=yes");
			}
		});
		window.open("http://wpa.qq.com/msgrd?v=3&uin=1679171821&site=qq&menu=yes");
		return false;
	});
	/*-----------------end 3.1通用 炫耀---------------*/
});